package cn.edu.tju.core.model;

public enum ResultCodeEnum {
    /*** 通用部分 100 - 599***/
    // 成功请求
    SUCCESS("OK", "successful"),
    // 资源未找到
    NOT_FOUND("NOT_FOUND", "not found"),
    // 服务器错误
    SERVER_ERROR("GENERAL_ERROR","server error"),
    // 参数错误
    PARAM_ERROR("PARAM_ERROR", "parameter error"),
    // 未授权
    UNAUTHORIZED("UNAUTHORIZED", "unauthorized"),
    // 禁止访问
    FORBIDDEN("FORBIDDEN", "forbidden"),
    // 请求超时
    TIMEOUT("TIMEOUT", "request timeout"),
    // 数据已存在
    DATA_EXISTS("DATA_EXISTS", "data already exists"),
    // 数据不存在
    DATA_NOT_FOUND("DATA_NOT_FOUND", "data not found"),
    // 操作失败
    OPERATION_FAILED("OPERATION_FAILED", "operation failed"),
    // 网络错误
    NETWORK_ERROR("NETWORK_ERROR", "network error"),
    // 数据库错误
    DATABASE_ERROR("DATABASE_ERROR", "database error"),
    // 文件操作错误
    FILE_ERROR("FILE_ERROR", "file operation error"),
    // 系统繁忙
    SYSTEM_BUSY("SYSTEM_BUSY", "system busy"),
    // 未知错误
    UNKNOWN_ERROR("UNKNOWN_ERROR", "unknown error"),

    /*** 这里可以根据不同模块用不同的区级分开错误码，例如:  ***/

    // 1000～1999 区间表示用户模块错误
    USER_NOT_FOUND("USER_NOT_FOUND", "user not found"),
    USER_EXISTS("USER_EXISTS", "user already exists"),
    USER_PASSWORD_ERROR("USER_PASSWORD_ERROR", "password error"),
    USER_DISABLED("USER_DISABLED", "user disabled"),
    USER_LOCKED("USER_LOCKED", "user locked"),
    USER_UNAUTHORIZED("USER_UNAUTHORIZED", "user unauthorized"),

    // 2000～2999 区间表示订单模块错误
    ORDER_NOT_FOUND("ORDER_NOT_FOUND", "order not found"),
    ORDER_CREATE_FAILED("ORDER_CREATE_FAILED", "order creation failed"),
    ORDER_UPDATE_FAILED("ORDER_UPDATE_FAILED", "order update failed"),
    ORDER_CANCEL_FAILED("ORDER_CANCEL_FAILED", "order cancellation failed"),
    ORDER_STATUS_ERROR("ORDER_STATUS_ERROR", "order status error"),

    // 3000～3999 区间表示商品模块错误
    PRODUCT_NOT_FOUND("PRODUCT_NOT_FOUND", "product not found"),
    PRODUCT_STOCK_INSUFFICIENT("PRODUCT_STOCK_INSUFFICIENT", "product stock insufficient"),
    PRODUCT_PRICE_CHANGED("PRODUCT_PRICE_CHANGED", "product price changed"),

    // 4000～4999 区间表示购物车模块错误
    CART_ITEM_NOT_FOUND("CART_ITEM_NOT_FOUND", "cart item not found"),
    CART_ADD_FAILED("CART_ADD_FAILED", "add to cart failed"),
    CART_UPDATE_FAILED("CART_UPDATE_FAILED", "cart update failed"),
    CART_DELETE_FAILED("CART_DELETE_FAILED", "cart deletion failed"),

    // 5000～5999 区间表示支付模块错误
    PAYMENT_FAILED("PAYMENT_FAILED", "payment failed"),
    PAYMENT_TIMEOUT("PAYMENT_TIMEOUT", "payment timeout"),
    PAYMENT_REFUND_FAILED("PAYMENT_REFUND_FAILED", "payment refund failed"),

    // 6000～6999 区间表示商家模块错误
    BUSINESS_NOT_FOUND("BUSINESS_NOT_FOUND", "business not found"),
    BUSINESS_CLOSED("BUSINESS_CLOSED", "business closed"),
    BUSINESS_UNAVAILABLE("BUSINESS_UNAVAILABLE", "business unavailable"),

    // 7000～7999 区间表示配送模块错误
    DELIVERY_FAILED("DELIVERY_FAILED", "delivery failed"),
    DELIVERY_TIMEOUT("DELIVERY_TIMEOUT", "delivery timeout"),
    DELIVERY_ADDRESS_ERROR("DELIVERY_ADDRESS_ERROR", "delivery address error")
    ;

    /**
     * 响应状态码
     */
    private String code;
    /**
     * 响应信息
     */
    private String message;

    ResultCodeEnum(String code, String msg) {
        this.code = code;
        this.message = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMessage() {
        return message;
    }
}
